import sys
import os


def main():
    # open the db
    conn = sqlite3.connect(os.path.join(os.getcwd(), 'speechviz2.sqlite'))
    c = conn.cursor()
    #create the sqlite table
    c.execute('''CREATE TABLE "speech_table" ("id" INTEGER PRIMARY KEY  NOT NULL , 
                                              "type" VARCHAR NOT NULL , 
                                              "date" DATETIME NOT NULL , 
                                              "president" VARCHAR NOT NULL , 
                                              "title" TEXT NOT NULL ,
                                              "paragraph_topic" VARCHAR NOT NULL ) 
              ''')
    conn.commit()
    for fname in os.listdir(sys.argv[1]):
        txt = open(sys.argv[1]+'/'+fname).read()
        fp = open(sys.argv[2]+'/'+fname+".speech", "w").write(txt)

    
if __name__ == "__main__":
    main()
    